interface ItemType{
    img:string,
    title:string,
    desc:string,
    text:string,
    id:string
}

interface dataType{
    map(arg0: (item: any) => void): string;
    code:number,
    data:ItemType[]
}

Ajax('/api/list',(data:dataType)=>{
    renderList(data.data)
})

function renderList(data:ItemType[]){
    const main:Element|null=document.querySelector('main');
    (main as Element).innerHTML=data.map(item=>{
        return`
            <dl class='wrap' id='${item.id}'>
                <dt><img src="${item.img}" alt=""></dt>
                <dd>
                    <h3>${item.title}</h3>
                    <p>${item.desc}</p>
                </dd>
            </dl>
        `
    }).join('')
    bindEvent()
}

function bindEvent(){
    const ItemDom=Array.from(document.querySelectorAll('dl'));
    ItemDom.forEach(item=>{
        item.addEventListener('click',()=>{
            location.href=`/detail?id=${item.id}&title=123`
        })
    })
}